const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpack = require('webpack');
const HotModuleReplacementPlugin = webpack.HotModuleReplacementPlugin;
module.exports = {
  mode: 'development',
  entry: {
    main: "./src/js/index.js",
  },
  output: {
      path: path.resolve(__dirname, './dist/'),
      filename: 'js/[name][hash:8].js',
      // publicPath: '//che_dabang/test/'
  },
  module: {
    rules: [
      {
        test: /\.vue$/,
        use: {
          loader: 'vue-loader'
        }
      },
      {
        test: /\.js$/,
        include: [
          path.resolve(__dirname, 'src/js/index.js'),
        ],
        loader: 'babel-loader'
      },
      {
        test: /\.(png|jpg|gif)$/,
        use: [{
          loader: 'url-loader',
          options: {
            limit: 8192,
             name: '[name][hash:8].[ext]',
            outputPath: 'img/'
          }
        }]
      },
      {
        test: /\.less$/,
        use: [{
          loader: 'style-loader'
        }, {
          loader: 'css-loader'
        }, {
          loader: 'less-loader'
        }]
      },
      {
        test: /js[\/|\\]lib[\/||\\][\w|\.|_|-]+js$/,
        use: 'url-loader?limit=1000&name=js/lib/[name].[ext]'
      },
      
    ]
  },
  plugins: [
    new HtmlWebpackPlugin({
      template: 'index.html'
    }),
    new HotModuleReplacementPlugin()
  ],
  devServer: {
    host: '0.0.0.0',
    contentBase: path.join(__dirname, './'),
    compress: true,
    port: 3000,
    inline: true,
    hot: true,
    disableHostCheck: true
  }
}